/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-01-12 09:35:49
 * @LastEditTime : 2023-06-05 15:17:42
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Configure\HLSSource.jsx
 * @Description  :
 */
import Hls from 'hls.js'
import { useEffect } from 'react'

export const HLSSource = ({ src, video }) => {
    useEffect(() => {
        const hls = new Hls()
        if (Hls.isSupported()) {
            hls.loadSource(src)
            hls.attachMedia(video)
            // hls.on(Hls.Events.MANIFEST_PARSED, () => video.play() )
        }
        return () => hls.destroy()
    }, [src, video])
    return <source src={src} type={'application/x-mpegURL'} />
}
